import request from '@/axios';
import {baseUrl} from "@/config/env";

export const getList = (current, size, params) => {
    return request({
        url:baseUrl + '/ucs-system/role/list',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}
export const grantTree = () => {
    return request({
        url:baseUrl +  '/ucs-system/menu/grant-tree',
        method: 'get',
    })
}

export const grant = (roleIds, menuIds, dataScopeIds) => {
    return request({
        url: baseUrl + '/ucs-system/role/grant',
        method: 'post',
        data: {
            roleIds,
            menuIds,
            dataScopeIds
        }
    })
}

export const remove = (ids) => {
    return request({
        url: baseUrl + '/ucs-system/role/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}

export const add = (row) => {
    return request({
        url: baseUrl + '/ucs-system/role/submit',
        method: 'post',
        data: row
    })
}

export const update = (row) => {
    return request({
        url: baseUrl + '/ucs-system/role/submit',
        method: 'post',
        data: row
    })
}


export const getRole = (roleIds) => {
    return request({
        url: baseUrl + '/ucs-system/menu/role-tree-keys',
        method: 'get',
        params: {
            roleIds,
        }
    })
}

export const getRoleTree = (tenantId) => {
    return request({
        url:baseUrl +  '/ucs-system/role/tree',
        method: 'get',
        params: {
            tenantId,
        }
    })
}

